package com.jl.thread;

import com.jl.utils.WebDriverUtils;
import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.ExecutorService;

/**
 * @author : ljl
 * @date : 15:10 2021/1/7
 */

@Component
@Slf4j
public class ThreadDtoUtils {

    /**
     * 多线程执行任务
     * @param j
     * @param webElementsTd
     * @param driver
     * @param executorService
     */
    public void asynTickets(int j, List<WebElement> webElementsTd, WebDriver driver, ExecutorService executorService) {
        executorService.execute(() -> {
            try {
                // 寻找车票
                WebDriverUtils.seekTickets(j, webElementsTd, driver);
            } catch (Exception e) {
                log.error("=========={}", e.getMessage());
            }
        });
    }
}
